package com.seal.commons.query;

import java.util.List;

/**
 * 功能描述: <br/>
 *
 * @author yong.huang
 * @date: 2020-06-24 15:12<br/>
 * @since JDK 1.8
 */
public class DefaultQueryResult<T> implements QueryResult<T>{

    private List<T> data;

    private T record;

    private QueryRequest request;

    public DefaultQueryResult(List<T> list, QueryRequest request){
        this.data = list;
        this.request = request;
    }

    public DefaultQueryResult(T record, QueryRequest request){
        this.record = record;
        this.request = request;
    }

    @Override
    public List<T> getList() {
        return data;
    }

    @Override
    public T getSingle() {
        if(this.request.getSingleQuery()){
            return record;
        }
        return null;
    }

    @Override
    public QueryRequest getRequest() {
        return request;
    }
}